/* 基础样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  color: #333;
  background: #f8f9fa;
  min-width: 380px;
  max-width: 420px;
}

/* 容器 */
.container {
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  position: relative;
}

/* 头部 */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  font-size: 20px;
}

.logo-text {
  font-weight: 600;
  font-size: 16px;
}

.settings-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s;
}

.settings-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.settings-btn span {
  font-size: 16px;
}

/* 当前搜索引擎 */
.current-engine {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
}

.current-engine .engine-icon {
  font-size: 18px;
  margin-right: 8px;
}

.current-engine .engine-name {
  flex: 1;
  font-weight: 500;
  font-size: 15px;
}

.switch-btn {
  background: #007bff;
  border: none;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  color: white;
}

.switch-btn:hover {
  background: #0056b3;
  transform: rotate(180deg);
}

/* 搜索容器 */
.search-container {
  padding: 20px;
  display: flex;
  gap: 8px;
}

.search-input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  font-size: 15px;
  transition: border-color 0.2s;
  outline: none;
}

.search-input:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.search-btn {
  background: #007bff;
  border: none;
  border-radius: 8px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s;
  color: white;
}

.search-btn:hover {
  background: #0056b3;
}

.search-btn span {
  font-size: 16px;
}

.favorite-search-btn {
  background: #ffc107;
  border: none;
  border-radius: 8px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s;
  color: white;
}

.favorite-search-btn:hover {
  background: #e0a800;
}

.favorite-search-btn span {
  font-size: 16px;
}

/* 搜索建议 */
.suggestions {
  max-height: 200px;
  overflow-y: auto;
  border-top: 1px solid #e9ecef;
  background: white;
}

.suggestion-item {
  padding: 12px 20px;
  cursor: pointer;
  border-bottom: 1px solid #f1f3f4;
  transition: background-color 0.2s;
}

.suggestion-item:hover {
  background: #f8f9fa;
}

.suggestion-item:last-child {
  border-bottom: none;
}

/* 搜索引擎选择器 */
.engine-selector {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: white;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.selector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #6c757d;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.close-btn:hover {
  background: #e9ecef;
}

.engine-grid {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
  flex: 1;
  overflow-y: auto;
}

.engine-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 8px;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  background: white;
}

.engine-item:hover {
  border-color: #007bff;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.engine-item.active {
  border-color: #007bff;
  background: #f0f8ff;
}

.engine-item .icon {
  font-size: 24px;
  margin-bottom: 8px;
}

.engine-item .name {
  font-size: 12px;
  text-align: center;
  font-weight: 500;
}

/* 快速操作按钮 */
.quick-actions {
  display: flex;
  border-top: 1px solid #e9ecef;
  background: #f8f9fa;
}

.action-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  border: none;
  background: none;
  cursor: pointer;
  transition: background-color 0.2s;
  color: #6c757d;
}

.action-btn:hover {
  background: #e9ecef;
  color: #495057;
}

.action-btn .btn-icon {
  font-size: 18px;
  margin-bottom: 4px;
}

.action-btn .btn-text {
  font-size: 11px;
  font-weight: 500;
}

/* 历史面板 */
.history-panel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: white;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
  font-weight: 600;
}

.panel-actions {
  display: flex;
  gap: 8px;
}

.clear-btn {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: #dc3545;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.clear-btn:hover {
  background: rgba(220, 53, 69, 0.1);
}

.history-list {
  flex: 1;
  overflow-y: auto;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid #f1f3f4;
  cursor: pointer;
  transition: background-color 0.2s;
}

.history-item:hover {
  background: #f8f9fa;
}

.history-content {
  flex: 1;
  min-width: 0;
}

.history-query {
  font-weight: 500;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-meta {
  font-size: 12px;
  color: #6c757d;
  display: flex;
  gap: 8px;
}

.history-time {
  color: #adb5bd;
}

/* 自定义引擎表单 */
.custom-engine-form {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: white;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
  font-weight: 600;
}

.form-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: #495057;
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #e9ecef;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s;
  outline: none;
}

.form-group input:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.form-group small {
  display: block;
  margin-top: 4px;
  color: #6c757d;
  font-size: 12px;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.cancel-btn,
.save-btn {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.cancel-btn {
  background: #6c757d;
  color: white;
}

.cancel-btn:hover {
  background: #545b62;
}

.save-btn {
  background: #007bff;
  color: white;
}

.save-btn:hover {
  background: #0056b3;
}

/* 状态消息 */
.status-message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 12px 20px;
  border-radius: 6px;
  font-size: 14px;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s;
}

.status-message.show {
  opacity: 1;
}

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* 响应式设计 */
@media (max-width: 400px) {
  .container {
    margin: 0;
    border-radius: 0;
  }

  .engine-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
  }

  .quick-actions {
    flex-wrap: wrap;
  }

  .action-btn {
    min-width: 60px;
  }
}

/* 深色主题 */
body.dark-theme {
  background: #1a1a1a;
  color: #e0e0e0;
}

body.dark-theme .container {
  background: #2d2d2d;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

body.dark-theme .current-engine {
  background: #3a3a3a;
  border-bottom-color: #444;
}

body.dark-theme .search-input {
  background: #3a3a3a;
  border-color: #555;
  color: #e0e0e0;
}

body.dark-theme .search-input:focus {
  border-color: #0d7377;
}

body.dark-theme .quick-actions {
  background: #3a3a3a;
  border-top-color: #444;
}

body.dark-theme .engine-item {
  background: #3a3a3a;
  border-color: #555;
}

body.dark-theme .engine-item:hover {
  border-color: #0d7377;
}

@media (prefers-color-scheme: dark) {
  body {
    background: #1a1a1a;
    color: #e0e0e0;
  }

  .container {
    background: #2d2d2d;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }

  .current-engine {
    background: #3a3a3a;
    border-bottom-color: #444;
  }

  .search-input {
    background: #3a3a3a;
    border-color: #555;
    color: #e0e0e0;
  }

  .search-input:focus {
    border-color: #0d7377;
  }

  .quick-actions {
    background: #3a3a3a;
    border-top-color: #444;
  }

  .engine-item {
    background: #3a3a3a;
    border-color: #555;
  }

  .engine-item:hover {
    border-color: #0d7377;
  }
}

/* 收藏功能样式 */
.favorite-item {
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background-color 0.2s ease;
}

.favorite-item:hover {
  background-color: #f8f9fa;
}

.favorite-content {
  flex: 1;
}

.favorite-query {
  font-weight: 500;
  color: #212529;
  margin-bottom: 4px;
}

.favorite-meta {
  display: flex;
  align-items: center;
  font-size: 0.8rem;
}

.favorite-engine {
  padding: 2px 6px;
  background-color: #e9ecef;
  border-radius: 10px;
  font-size: 0.7rem;
  color: #495057;
  margin-right: 0.5rem;
}

.favorite-time {
  font-size: 0.75rem;
  color: #6c757d;
  margin-left: 0.5rem;
}

.favorite-remove {
  background: none;
  border: none;
  font-size: 16px;
  color: #ffc107;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.favorite-remove:hover {
  background-color: #fff3cd;
  transform: scale(1.1);
}

.favorite-add {
  background: none;
  border: none;
  font-size: 14px;
  color: #6c757d;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: all 0.2s ease;
  margin-left: 8px;
}

.favorite-add:hover {
  color: #ffc107;
  transform: scale(1.1);
}

/* 暗色主题下的收藏样式 */
@media (prefers-color-scheme: dark) {
  .favorite-item:hover {
    background-color: #3a3a3a;
  }

  .favorite-query {
    color: #e0e0e0;
  }

  .favorite-engine {
    background-color: #555;
    color: #e0e0e0;
  }

  .favorite-time {
    color: #aaa;
  }
}
